package com.jron.cqiu.kernel.process;

import com.jron.cqiu.kernel.util.SystemProperties;
import com.jron.cqiu.util.Instance;

/**
 * Created by Intellij IDEA.
 *
 * @Author: Yejw
 * @Date: 2008-6-13
 * @Time: 9:33:04
 */
public class ProcessProxy implements IProcess, Instance {

    /**
     * 结束进程
     *
     * @param moduleBaseName
     * @param ignoreCase     映像名称是否忽略大小写
     * @return
     */
    public int kill(String moduleBaseName, boolean ignoreCase) {
        switch (SystemProperties.SYSTEM) {
            case WINDOWS:
            case LINUX:
                PROCESS_JNATIVE_INSTANCE.kill(moduleBaseName, ignoreCase);
                break;
        }
        return 0;
    }

    /**
     * 结束进程 默认忽略映像名称大小写
     *
     * @param moduleBaseName
     * @return
     */
    public int kill(String moduleBaseName) {
        return kill(moduleBaseName, true);
    }

    /**
     * 根据PID结束进程
     *
     * @param moduleBaseName
     * @return
     */
    public int kill(int pid) {
        switch (SystemProperties.SYSTEM) {
            case WINDOWS:
                PROCESS_WINP_INSTANCE.kill(pid);
                break;
            case LINUX:
                PROCESS_JNATIVE_INSTANCE.kill(pid);
                break;
        }
        return 0;
    }
}
